package com.smile.ye.http;

import com.smile.ye.data.dto.ProductMenuCreateDto;
import com.smile.ye.data.dto.ProductMenuQueryDto;
import com.smile.ye.data.dto.ProductMenuUpdateDto;
import com.smile.ye.response.Result;
import com.smile.ye.service.ProductMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "菜单管理")
@RestController
@RequestMapping("/products/menus")
public class ProductMenuController {
    @Autowired
    ProductMenuService service;

    @GetMapping
    @ApiOperation("分页查询")
    public Result query(ProductMenuQueryDto dto) {
        return service.query(dto);
    }

    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    public Result queryById( @PathVariable String id){
    return  service.queryById(id);
    }

    @PostMapping
    @ApiOperation("创建菜单")
    public Result create(@RequestBody ProductMenuCreateDto dto) {
        return service.create(dto);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改菜单")
    public Result update(@PathVariable  String id,@RequestBody ProductMenuUpdateDto dto) {
        return service.update(id, dto);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public Result remove(@PathVariable String id) {
        return service.remove(id);
    }

}
